package com.iwhalecloud.uncc.dao.impl;

import com.iwhalecloud.uncc.dao.ArchiverDao;
import com.iwhalecloud.uncc.model.InsCollectServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zq
 * @date 2021/10/27 9:54
 * @description InsCollectServerArchiverDaoImpl
 */
@Repository("insCollectServerArchiverDao")
public class InsCollectServerArchiverDaoImpl implements ArchiverDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public Object query(Object o) {
        return null;
    }

    /**
     * List
     * @param o
     * @return
     */
    @Override
    public List queryList(Object o) {
        StringBuilder sql = new StringBuilder("SELECT");
        sql.append(" `ID`, `SERVER_NAME`, `SERVER_MODEL`, `SERVER_TYPE`, `CPU`, `RAM`, `ROM`, `IP`, `USERNAME`, `PASSWORD`, `STATE`, `USED_STATE`, `SERVER_DESC`, `CPU_REMAINING`, `MEN_REMAINING`, `DISK_REMAINING`, `PORT`");
        sql.append(" FROM INS_COLLECT_SERVER");
        List<InsCollectServer> list = jdbcTemplate.query(sql.toString(),
                new BeanPropertyRowMapper<>(InsCollectServer.class));
        if (!list.isEmpty()) {
            return list;
        }
        return null;
    }

    @Override
    public List batchQuery(List list) {
        return null;
    }

    @Override
    public void insert(Object o) {

    }

    @Override
    public void batchInsert(List list) {

    }

    @Override
    public void update(int flag, Object o) {

    }

    @Override
    public void batchUpdate(int flag, List list) {

    }

    @Override
    public void delete(Object o) {

    }

    @Override
    public void batchDelete(List list) {

    }
}
